@extends('backend.layouts.app')

@section('content')
<div class="layui-card">
    <div class="layui-card-header layui-card-header-auto">
        <div class="layui-row">
            <div class="layui-col-md9">同类型岗位列表 -- <span style="color:red;">{{$station_type->name}}</span> -- 分配岗位
            </div>
        </div>
    </div>
    <div class="layui-card-body">
        <div id="test1"></div>
        <div>
            <button type="button" class="layui-btn" id="postData">提交</button>
            <a class="layui-btn" href="{{route('admin.resume.station_type.index')}}">返 回</a>
        </div>
    </div>
</div>
@endsection

@section('script')
<script type="text/javascript">
    layui.use(['layer', 'transfer', 'jquery'], function () {
        let layer = layui.layer;
        let transfer = layui.transfer;
        let $ = layui.jquery;
        $.ajax({
            url: "{{route('admin.resume.station_type.list.type',['id'=> $station_type->type_id])}}",
            success: function (data) {
                transfer.render({
                    elem: '#test1',
                    title: ['待分配岗位列表', '该分类岗位列表'],
                    data: data.data.noHasType,
                    id: 'demo1',
                    value: data.data.hasType
                });
            }
        });
        $(document).on('click', '#postData', function () {
            let getData = transfer.getData('demo1');
            $.ajax({
                url: "{{route('admin.resume.station_type.store.type',['id'=> $station_type->type_id])}}",
                data: {
                    data: getData,
                    _token: "{{csrf_token()}}"
                },
                type: "post",
                success: function (data) {
                    layer.msg('保存成功');
                    window.location.href = "{{route('admin.resume.station_type.index')}}";
                }
            });
        });
    });

</script>
@endsection
